package com.xq.shop.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xq.shop.config.FileConfig;
import com.xq.shop.dao.domain.entity.MyFile;
import com.xq.shop.dao.domain.entity.Order;
import com.xq.shop.dao.domain.entity.OrderGoodsImage;
import com.xq.shop.dao.mapper.OrderGoodsImageMapper;
import com.xq.shop.dto.IntegerDto;
import com.xq.shop.dto.OrderGoodsImageDto;
import com.xq.shop.service.IFileService;
import com.xq.shop.service.IOrderGoodsImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xq.shop.vo.FileVo;
import com.xq.shop.vo.OrderGoodsImageVo;
import com.xq.shop.vo.OrderGoodsVo;
import enums.ResultCodes;
import exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import utils.BaseConstants;

import javax.annotation.Resource;
import java.io.File;
import java.util.Calendar;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 * 订单商品图片表 服务实现类
 * </p>
 *
 * @author gaoxiaojin
 * @since 2024-07-30
 */
@Service
@Slf4j
public class OrderGoodsImageServiceImpl extends ServiceImpl<OrderGoodsImageMapper, OrderGoodsImage> implements IOrderGoodsImageService {

    @Override
    public List<OrderGoodsImageVo> selectOrderGoodsImageByOrderId(IntegerDto dto) {
        return baseMapper.selectOrderGoodsImageByOrderId(dto);
    }

    @Override
    public void addOrderGoodsImage(Integer orderId,Integer orderGoodsId,Integer imageId,Integer userId) {
        OrderGoodsImage orderGoodsImage = new OrderGoodsImage();
        orderGoodsImage.setOrderId(orderId);
        orderGoodsImage.setOrderGoodsId(orderGoodsId);
        orderGoodsImage.setImageId(imageId);
        orderGoodsImage.setCreateUser(userId);
        save(orderGoodsImage);
    }

    @Override
    public void removeOrderGoodsImage(IntegerDto dto) {
        OrderGoodsImage orderGoodsImage = getOne(new LambdaQueryWrapper<OrderGoodsImage>().eq(OrderGoodsImage::getImageId,dto.getValue()));
        orderGoodsImage.setStatus(0);
        updateById(orderGoodsImage);
    }
}
